package com.example.controller;

import com.example.pojo.Product;
import com.example.service.ProductService;
import com.example.service.impl.ProductServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author yinyin
 * @create 2021/07/14 下午 3:09
 */
@RestController
@RequestMapping("product")
public class ProductController {
    @Autowired
    ProductService productService;

    @GetMapping("list")
    public List<Product> selectList(){

        try {
           Thread.sleep(2000);
        }catch (InterruptedException e){
             e.printStackTrace();
        }
        return productService.selectProductList();
    }

    @GetMapping("/listByIds")
    public List<Product> selectByIds(@RequestParam("id") List<Integer> ids){
        return  productService.selectProductListByIds(ids);
    }

    @GetMapping("/listById/{id}")
    public Product selectOne(@PathVariable("id") Integer id){
        return  productService.selectProductById(id);
    }

}
